#include("../../comm/ListHead.html")
<div class="layui-fluid padding-10">
    <div class="layui-row layui-col-space5">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-header SearchTable">
                    <input type="hidden" id="menu_id" name="menu_id" value="#(form.data.menu_id??)"/>
                    <label class="table-search-title">访问路经:</label>
                    <input type="text" id="actpath" class="table-search-text width200" autocomplete="off">
                    <button class="layui-btn layui-btn-warm layui-btn-sm" lay-event="DoSearch">
                        搜索
                    </button>
                    <button class="layui-btn layui-btn-warm layui-btn-sm btn-close" lay-event="closeWindow">
                        关闭窗口
                    </button>
                </div>
                <div class="layui-card-body">
                    <table class="layui-hide" id="table_1" lay-filter="table_1"></table>

                    <script type="text/html" id="tpldr">
                        {{- d.act_cai }}
                    </script>
                    <script type="text/html" id="tmpLog">
                        <input type="checkbox" field="is_log" msg="记录日志" value="{{d.act_id}}" lay-skin="primary"
                               lay-filter="ChangeTag" {{ d.is_log ? 'checked' : '' }}>
                    </script>
                </div>
            </div>
        </div>
    </div>
</div>
<script language="JavaScript">

    layui.use(['myTable', 'table', 'form', 'myTool'], function () {
        admin = layui.admin, table = layui.table, form = layui.form,
                tree = layui.tree, myTool = layui.myTool, myTable = layui.myTable;
        var $ = layui.$;

        tableindex = layui.myTable.render({
            elem: '#table_1', url: 'AllSysActivityDataApi'
            , toolbar: false, title: '功能列表', where: {menu_id: $("#menu_id").val()}
            , height: 'full-62'
            , cols: [[
                {field: 'act_id', title: '功能ID', width: 80, align: 'center'}
                , {field: 'act_name', title: '功能名称', width: 100, edit: 'text'}
                , {field: 'act_path', title: '访问路经', width: 350}
                , {field: 'act_role_name', title: '功能权限(角色)'}
                , {field: 'act_user_name', title: '功能权限(人员)'}
                , {field: 'log', title: '日志', width: 60, align: 'center', templet: '#tmpLog'}
                , {fixed: 'right', title: '操作', toolbar: '#tpldr', width: 70, align: 'center'}
            ]]
            , page: true, limit: 9
            , editField: {url: 'ModifySysActivityFieldApi', key: 'act_id'}
        });

        layui.util.event("lay-event", {
            DoSearch: function () {
                tableindex.reload({
                    where: {
                        menu_id: $("#menu_id").val(),
                        actpath: $("#actpath").val()
                    }
                    , page: {curr: 1}
                });
            }
            , closeWindow: function () {
                parent.layer.closeAll();
            }
        });
        //监听行工具事件
        table.on('tool(table_1)', function (obj) {
            var data = obj.data;
            if (obj.event === 'DrSysActivity') {//
                myTool.post("DrSysActivityApi", {
                    act_id: data.act_id, menu_id: $("#menu_id").val()
                }, function () {
                    layer.close();
                    tableindex.reload();
                });
            } else if (obj.event === 'DelSysActivity') {
                index = layer.confirm('你是否确认删除【' + data.act_path + '】', {icon: 3, title: '提示', offset: '100px'}, function (index2) {
                    myTool.postMsg("DelSysActivityApi", {act_id: data.act_id}, function () {
                        layer.close(index2);
                        tableindex.reload();
                    });
                });
            }
        });

        form.on('checkbox(ChangeTag)', function (obj) {
            myTool.postMsg("ChangeSysActivityColumnApi", {act_id: this.value, field: $(obj.elem).attr("field"), msg: $(obj.elem).attr("msg")}, function (result) {
                layer.tips(result.msg, obj.othis);
            });
        });
    });
</script>
#include("../../comm/Foot.html")